import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;


public class FlowLayoutFrame extends JFrame {
    
    private JButton leftButton;
    private JButton centerButton;
    private JButton rightButton;
    
    private FlowLayout layout;
    private Container container;
    
    public FlowLayoutFrame(){
	super("FlowLayoutFrame");
	layout = new FlowLayout();
	container = getContentPane();
	container.setLayout(layout);
	
	leftButton = new JButton("LEFT");
	leftButton.addActionListener(new ActionListener() {
	    
	    @Override
	    public void actionPerformed(ActionEvent e) {
		layout.setAlignment(FlowLayout.LEFT);
		layout.layoutContainer(container);
		
	    }
	});
	
	centerButton = new JButton("CENTER");
	centerButton.addActionListener(new ActionListener() {
	    
	    @Override
	    public void actionPerformed(ActionEvent e) {
		layout.setAlignment(FlowLayout.CENTER);
		layout.layoutContainer(container);
		
	    }
	});
	
	rightButton = new JButton("RIGHT");
	rightButton.addActionListener(new ActionListener() {
	    
	    @Override
	    public void actionPerformed(ActionEvent e) {
		layout.setAlignment(FlowLayout.RIGHT);
		layout.layoutContainer(container);
		
	    }
	});
	
	add(leftButton);
	add(centerButton);
	add(rightButton);
    }

}
